#include <stdio.h>
#include "lexical.h"
#include "error.h"


#ifdef T0 // 基本功能测试
int main(int argc, const char *argv[])
{
    if (argc < 2)
        return -1;
    FILE *file  = fopen(argv[1], "r");
    if(!file) {
        printf("文件打开失败\n");
        return -2;
    }
    scanner_set_file_and_name(file, argv[1]);
    check_symbol_num();
    do {
        get_token();
        if(FILE_END == scanner_get_cur_token())
            break;
        else
            show_token(scanner_get_cur_token());
    } while(1);

    return 0;
}
#endif



#ifdef T1 // 词法上色测试
int main(int argc, const char *argv[])
{
    if (argc < 2)
        return -1;
    FILE *file  = fopen(argv[1], "r");
    if(!file) {
        printf("文件打开失败\n");
        return -2;
    }
    scanner_set_file_and_name(file, argv[1]);
    check_symbol_num();
    do {
        get_token();
        if(FILE_END == scanner_get_cur_token())
            break;
        else 
           show_color_token(scanner_get_cur_token());
    } while(1);

    return 0;
}
#endif

#ifdef T2 // 错误处理测试
int main(int argc, const char *argv[])
{
    if (argc < 2)
        return -1;
    FILE *file  = fopen(argv[1], "r");
    if(!file) {
        printf("文件打开失败\n");
        return -2;
    }
    scanner_set_file_and_name(file, argv[1]);
    check_symbol_num();
    do {
        get_token();
        if(FILE_END == scanner_get_cur_token())
            break;

    } while(1);
    show_error_num();
    return 0;
}
#endif